<?php

$installer = $this;

$installer->startSetup();

$installer->run("

-- DROP TABLE IF EXISTS {$this->getTable('relay')};
CREATE TABLE IF NOT EXISTS {$this->getTable('relay')} (
  `relay_id` int(11) unsigned NOT NULL auto_increment,
  `city` varchar(255) NOT NULL default '',
  `title` varchar(255) NOT NULL default '',
  `desc` varchar(255) NOT NULL default '',
	
  `glat` varchar(33) NOT NULL default '',
  `glng` varchar(33) NOT NULL default '',
  `address` text NOT NULL default '',
  `contact` text NOT NULL default '',
	
  `status` smallint(6) NOT NULL default '1',
  `created_time` datetime NULL,
  `update_time` datetime NULL,
  PRIMARY KEY (`relay_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

REPLACE INTO {$this->getTable('relay')} 
	(`relay_id`, `city`,`title`, `desc`
		, `glat`, `glng`, `address`, `contact`
		, `status`, `created_time`, `update_time`) 
VALUES
	( 1, 'Saigon', 'Relay 1', 'Quan 1'
		, '10,123456', '111,123456', '1 duong XYZ', 'Mr ABC'
		, 1, '2010-10-12 10:42:08', '2010-10-12 10:42:08');


CREATE TABLE IF NOT EXISTS {$this->getTable('relay_deal')} (
  `relay_id` INT NOT NULL ,
	`deal_id` INT NOT NULL ,
	`status` TINYINT NOT NULL ,
	`created_time` DATETIME NOT NULL ,
	`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`relay_id`, `deal_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

REPLACE INTO {$this->getTable('relay_deal')} 
	(`relay_id`, `deal_id`, `status`) 
VALUES
	( 1, 1, 1);
	

CREATE TABLE IF NOT EXISTS {$this->getTable('relay_quote')} (
  `relay_id` INT NOT NULL ,
	`quote_id` INT NOT NULL ,
	`status` TINYINT NOT NULL ,
	`created_time` DATETIME NOT NULL ,
	`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`relay_id`, `quote_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

REPLACE INTO {$this->getTable('relay_quote')} 
	(`relay_id`, `quote_id`, `status`) 
VALUES
	( 1, 1, 1);	
	

CREATE TABLE IF NOT EXISTS {$this->getTable('relay_order')} (
  `relay_id` INT NOT NULL ,
	`order_id` INT NOT NULL ,
	`status` TINYINT NOT NULL ,
	`created_time` DATETIME NOT NULL ,
	`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`relay_id`, `order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

REPLACE INTO {$this->getTable('relay_order')} 
	(`relay_id`, `order_id`, `status`) 
VALUES
	( 1, 1, 1);		

");

$installer->endSetup(); 